<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<sys:header title="公司管理 - ${company.isNewRecord ? '新增' : '编辑'}公司" extLibs="validate"/>
<div class="portlet box ${boxStyleColor} autoHeight">
	<div class="portlet-title">
		<div class="caption"><i class="fa fa-coffee"></i>${company.isNewRecord ? '新增' : '编辑'}公司</div>
	</div>
	<div class="portlet-body form">
		<form:form id="inputForm" modelAttribute="company" action="${ctx}/sys/company/save" method="post" class="form-horizontal">
			<div class="form-body">
				<h4 class="form-section">基本信息</h4>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">上级公司：</label>
							<div class="col-sm-8">
								<sys:treeselect id="parent" name="parent.companyCode" value="${company.parent.companyCode}" labelName="parent.companyName" labelValue="${company.parent.companyName}"
									title="上级公司" url="/sys/company/treeData" extCode="${company.companyCode}" isShowCode="true" cssClass="" allowClear="true" />
								<span class="help-block">&nbsp;</span>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4"><span class="required">*</span> 公司编码：</label>
							<div class="col-sm-8">
								<form:hidden path="isNewRecord"/>
								<form:hidden path="companyCode"/>
								<form:input path="viewCode" htmlEscape="false" maxlength="30" readonly="${!company.isNewRecord}" class="form-control abc required"/>
								<span class="help-block">&nbsp;</span>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4"><span class="required">*</span> 公司简称：</label>
							<div class="col-sm-8">
							<input id="oldCompanyNameSimple" name="oldCompanyNameSimple" type="hidden" value="${company.companyNameSimple}">
							<form:input path="companyNameSimple" htmlEscape="false" maxlength="100" class="form-control required"/>
							<span class="help-block">&nbsp;</span>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4"><span class="required">*</span> 公司全称：</label>
							<div class="col-sm-8">
								<form:input path="companyName" htmlEscape="false" maxlength="100" class="form-control required"/>
								<span class="help-block">&nbsp;</span>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="设置该公司包含的组织机构，在选择机构时可根据公司筛选。">
								包含机构：<i class="fa icon-question"></i></label>
							<div class="col-sm-8">
							<sys:treeselect id="office" name="office.id" value="${company.office.id}" labelName="office.officeName" labelValue="${company.office.officeName}"
								title="机构" url="/sys/office/treeData" isShowCode="true" cssClass="form-control" checked="true" notAllowSelectParent="true" allowClear="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">注册地区：</label>
							<div class="col-sm-8">
								<sys:treeselect id="area" name="area.id" value="${company.area.id}" labelName="area.areaName" labelValue="${company.area.areaName}"
									title="注册地区" url="/sys/area/treeData" allowClear="true" isShowCode="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">备注：</label>
							<div class="col-sm-10">
								<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="form-control"/>
								<span class="help-block">&nbsp;</span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-actions fluid">
				<div class="row">
					<div class="col-xs-12">
						<div class="col-sm-offset-2 col-sm-10">
							<shiro:hasPermission name="sys:company:edit">
								<button id="btnSubmit" type="submit" class="btn btn-primary" ><i class="fa fa-check"></i> 保 存</button>&nbsp;
							</shiro:hasPermission>
							<button id="btnCancel" type="button" class="btn default" onclick="closeCurrentTabPage('${param.parentTabPageId}')"><i class="fa fa-reply-all"></i> 关 闭</button>
						</div>
					</div>
				</div>
			</div>
		</form:form>
	</div>
</div>
<sys:footer extLibs="validate"/>
<script type="text/javascript">
	if("${company.status}"=="2"){
		$('input').attr("disabled","disabled");
		$('textArea').attr("disabled","disabled");
		$('button[type="submit"]').addClass('display-none');
	}
	$("#inputForm").validate({
		submitHandler: function(form){
			ajaxSubmitForm($(form), function(data){
				showMessage(data.message);
				if(data.result== Global.TRUE){
					showMessage('本次操作之后仅显示本级数据，若想查看全部数据，请点击“全部”按钮。', '', 'info', 3000);
					closeCurrentTabPage('${param.parentTabPageId}', function(contents, contentWindow){
						contentWindow.dataGrid.refreshTree(1, $('#parentCode').val());
					});
				}
			}, "json");
	    }
	});
</script>